import { Events, REST } from 'discord.js';
import bot from '../../bot';
import { TOKEN } from '../../util/env';
import { commandRegistry } from '../commandRegistry';
import registerCommandsInGuild from '../../util/registerCommands';

bot.on(Events.GuildCreate, guild => {
  const rest = new REST().setToken(TOKEN ?? bot.token!);
  const commands = commandRegistry.map(v => v.toJSON());
  registerCommandsInGuild(rest, guild.id, bot.user!.id, commands);
});
